package com.seeyon.apps.kk.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.collections.MapUtils;
import org.springframework.web.servlet.ModelAndView;

import com.seeyon.ctp.common.AppContext;
import com.seeyon.ctp.common.authenticate.domain.User;

public class LoginExchangeController extends KkBaseController{

	public ModelAndView postExchange(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(ROOT_PATH + "/json/loginExchange");
		User user = AppContext.getCurrentUser();
		mav.addObject("username", user.getLoginName());
		Map<String, Object> map = new HashMap<>();
		map.put("id", user.getId());
		List<Map<String, Object>> list = this.ibatisQueryDao.queryForList("password_select_lockkk", map);
		Map<String, Object> result =  list.get(0);
		mav.addObject("password", MapUtils.getString(result, "pwd"));
		return mav;
	}
	
	public ModelAndView postHT(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(ROOT_PATH + "/json/loginHTSystem");
		User user = AppContext.getCurrentUser();
		mav.addObject("username", user.getLoginName());
		Map<String, Object> map = new HashMap<>();
		map.put("id", user.getId());
		List<Map<String, Object>> list = this.ibatisQueryDao.queryForList("password_select_lockkk", map);
		Map<String, Object> result =  list.get(0);
		mav.addObject("password", MapUtils.getString(result, "pwd"));
		return mav;
	}
	
	public ModelAndView postEA(HttpServletRequest request, HttpServletResponse response) throws Exception {
		ModelAndView mav = new ModelAndView(ROOT_PATH + "/json/loginEASystem");
		User user = AppContext.getCurrentUser();
		mav.addObject("username", user.getLoginName());
		Map<String, Object> map = new HashMap<>();
		map.put("id", user.getId());
		List<Map<String, Object>> list = this.ibatisQueryDao.queryForList("password_select_lockkk", map);
		Map<String, Object> result =  list.get(0);
		mav.addObject("password", MapUtils.getString(result, "pwd"));
		return mav;
	}
}